package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupGraveYard;

/**
 * Denne klasse bruges til at hente al data i bs_grave_yard og returnere det
 * @author junjie
 */
public abstract class BackupGraveYardHandler {
    
    /**
     * Henter alle rækker i bs_grave_yard og returnere et BackupGraveYard[] model
     * @return BackupGraveYard[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
    public static BackupGraveYard[] getBackupGraveYards() throws ClassNotFoundException, SQLException{
        BackupGraveYard[] backupGraveYards = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_grave_yard", "", "", "", "id", "name", "fk_address_id");
        backupGraveYards = new BackupGraveYard[result.length];
        
        db.closeDB();
        
        for (int i = 0; i < result.length; i++) {
            backupGraveYards[i] = new BackupGraveYard(Integer.parseInt(result[i][0]), result[i][1], Integer.parseInt(result[i][2]));
        }
        return backupGraveYards;
    }
 }
